package GameConfig

import (
	xml "misc/dom4g"
	log "misc/seelog"
	"os"
	cfg "utils/config"
)

const xmlEffectPath = "GameCore/Effects.xml"

var xmlEffectMap map[string]*xml.Element

func loadXmlEffect() {
	xmlEffectMap = make(map[string]*xml.Element)
	path := cfg.Get()["GameConfigPath"] + xmlEffectPath
	f, err := os.Open(path)
	if err != nil {
		log.Info(err)
	}
	xmldoc, err2 := xml.LoadByStream(f)
	if err2 != nil {
		log.Info(err2)
	}

	for _, v := range xmldoc.Root().AllNodes() {
		effectName, _ := v.AttrValue("Name")
		xmlEffectMap[effectName] = v
	}
}

func GetXmlEffect(effectName string) *xml.Element {

	return xmlEffectMap[effectName]
}
